using System;
using System.Data.Linq.Mapping;
using CoreLibrary.Date;
using Entities.DataBase.Persistent.Jso;
using Newtonsoft.Json;

namespace Entities.DataBase.Persistent {

    [Table(Name = "D_CUSTOMER")]
    public class Customer {

        public Customer() {
            Data         = string.Empty;
            DateCreated  = DateTime.UtcNow;
            DateUpdated  = DateUtil.Epoch;
            Enabled      = true;
        }

        [Column(Name = "ID", IsPrimaryKey = true)]
        public string Id            { get; set; }

        [Column(Name = "NAME")]
        public string Name          { get; set; }

        [Column(Name = "C_NAME")]
        public string CName         { get; set; }

        [Column(Name = "SEX")]
        public int Sex              { get; set; }

        [Column(Name = "PHONE_NUMBER_1")]
        public string PhoneNumber1  { get; set; }

        [Column(Name = "PHONE_NUMBER_2")]
        public string PhoneNumber2  { get; set; }

        [Column(Name = "PHONE_NUMBER_3")]
        public string PhoneNumber3  { get; set; }

        [Column(Name = "QQ")]
        public string QQ            { get; set; }

        [Column(Name = "WEIXIN")]
        public string Weixin        { get; set; }
        
        [Column(Name = "EMAIL1")]
        public string Email1        { get; set; }

        [Column(Name = "EMAIL2")]
        public string Email2        { get; set; }

        [Column(Name = "EMAIL3")]
        public string Email3        { get; set; }

        [Column(Name = "ADDRESS1")]
        public string Address1      { get; set; }

        [Column(Name = "ADDRESS2")]
        public string Address2      { get; set; }

        [Column(Name = "ADDRESS3")]
        public string Address3      { get; set; }

        [Column(Name = "DATA")]
        public string Data          { get; set; }

        [Column(Name="ENABLED")]
        public bool Enabled { get; set; }

        [Column(Name = "DATE_CREATED")]
        public DateTime DateCreated { get; set; }

        [Column(Name = "DATE_UPDATED")]
        public DateTime DateUpdated { get; set; }

        // Temprary store customer profile
        public CustomerProfile Profile {
            get {
                return JsonConvert.DeserializeObject<CustomerProfile>(Data);
            }
        }
    }

}